var _regions=new Array() 
_regions[0]="ef_region_inqu";
_regions[1]="ef_region_result";
_regions[2]="details"; 
_regions[3]="ef_region_mainadd";
_regions[4]="ef_region_solveadd"; 
_regions[5]="ef_region_penaltyadd"; 
_regions[6]="ef_region_previewadd"; 
var isNoSlove = true;
efform_onload = function ()
{  
	InitRegionShow(); 
 	
	var _info = new EiInfo();
	EiCommunicator.send("ZMCC13", "query", _info, ajax_select_callback);  
	EiCommunicator.send("ZMCC14", "query", _info, ajax_select_callback1); 
};   
function InitRegionShow()
{
	hideAllRegions(_regions); 
	$('#ef_region_inqu').show(); 
	$('#ef_region_result').show(); 
//	$('#details').show(); 
	efbutton.setButtonStatus("mainconfirm", true);
	efbutton.setButtonStatus("maincancel", true);
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCC11","query"); 
}
button_query_onclick = function ()//QUERY 查询 
{
	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCC11","query");
} 
/*************************************************************************
*************************************************************************
	下达整改通知 方法 张坤2016年3月30日17:21:39
*************************************************************************
*************************************************************************/
button_handle_onclick = function ()//HANDLE 下达整改通知 
{
	var grid=isSelectedOne("ef_grid_r");
	if (grid == 0)return; 
	var selectedRow=grid.getSelectRowsData()[0]; 
//	if(selectedRow["fdProblemStatus"]!=3)
//	{
//		SCZXAlertError("只能对未整改状态记录做次操作！");
//		return;
//	}
	for(var item in selectedRow){
		var colname=item;
		var colvalue=selectedRow[item];
		$('#result_add-0-'+colname).val(colvalue); 
		$('#result_add-0-'+colname).attr("readonly","readonly");
		$('#result_add-0-'+colname).attr("disabled","disabled");
	} 
    //默认主表赋值，构造日期时间
	$('#result_add-0-fdProblemDateTime').val($('#result_add-0-fdProblemDate').val()+" "+$('#result_add-0-fdProblemTime').val());
	$('#result_add-0-fdDeadlineDateTime').val($('#result_add-0-fdDeadlineDate').val()+" "+$('#result_add-0-fdDeadlineTime').val());
    //默认赋值
	$('#solve_add-0-fdRecordId').val($('#result_add-0-fdKeyId').val());
	$('#solve_add-0-fdHandlePeople').val($('#fdCreator').val());
	$('#solve_add-0-fdHandlePeople').attr("readonly","readonly");
	$('#solve_add-0-fdHandlePeopleId').val($('#fdCreatorId').val()); 
	$('#solve_add-0-fdCreateTime').val(getNowDateTime());
	$('#solve_add-0-fdHandleDate').val(getNowDate());
	$('#solve_add-0-fdStatus').val(1);
	$('#solve_add-0-fdBusinessDepartmentId').val($('#result_add-0-fdBusinessDepartmentId').val());
	hideAllRegions(_regions);
	$('#ef_region_mainadd').show();  
	efbutton.setButtonStatus("mainconfirm", false);
	efbutton.setButtonStatus("maincancel", false);
	$('#ef_region_solveadd').show(); 
} 

button_solveconfirm_onclick = function()// HANDLE 主表 确定
{
	var isCheck = checkHandle();
	if (isCheck == 0) {
		return;
	}
	if (efvalidateDiv("ef_region_solveadd")) {
		if ($('#solve_add-0-fdIsPenalty').val() == "否") {

			var info = getDetailbyBlockname("ef_region_solveadd", "solve_add");
			if (null != info) {
				EiCommunicator.send("ZMCC13", "insert", info, ajax_solveconfirm_callback1);
			}

		} else {
			isNoSlove = false;
			// 初始化罚款页面
			$('#penalty_add-0-fdPenalty').val(1);
			$('#penalty_add-0-fdSendnoteDate').val(getNowDate());
			$('#penalty_add-0-fdSendnoteDepartmentId').val($('#fdCreateDepartmentId').val());
			$('#penalty_add-0-fdDepartmentId').val($('#solve_add-0-fdBusinessDepartmentId').val());
			// $('#solve_add-0-fdBusinessDepartmentId').val($('#result_add-0-fdBusinessDepartmentId').val());
			$('#penalty_add-0-fdSendnotePersonId').val($('#fdCreatorId').val());
			$('#penalty_add-0-fdSendnotePerson').val($('#fdCreator').val());

//			$('#penalty_add-0-fdRecordId').val(eiInfo.get("fdRecordId"));
//			$('#penalty_add-0-fdHandleId').val(eiInfo.get("fdHandleId"));
			$('#penalty_add-0-fdSendnoteDepartmentId').attr("disabled", "disabled");
			$('#penalty_add-0-fdDepartmentId').attr("disabled", "disabled");
			hideAllRegions(_regions);
			$('#ef_region_penaltyadd').show();

		}
	}
} 
var ajax_solveconfirm_callback1= {
		onSuccess: function(eiInfo) {
			var grid = efgrid.getGridObject("ef_grid_s");
			grid.refresh(eiInfo);//刷新主表grid
			InitRegionShow();
			clearAfterSolve("ef_region_solveadd");

		},
		onFail:function(eMsg)
		{
			SCZXAlertError("操作失败，原因："+eMsg); 
		}
	}


button_solvecancel_onclick = function ()//HANDLE 主表 返回
{
	InitRegionShow();
} 

/*************************************************************************
*************************************************************************
	复查方法 张坤2016年3月31日15:44:36
*************************************************************************
*************************************************************************/
button_recheck_onclick = function ()//RECHECK 复查意见 
{
	var grid=isSelectedOne("ef_grid_r");
	if (grid == 0)return; 
	var selectedRow=grid.getSelectRowsData()[0]; 
	
	$('#preview_add-0-fdIsRepeat').val(selectedRow["fdIsRepeat"]); 
	
	var _info = new EiInfo();
	_info.set("fdRecordId",selectedRow["fdKeyId"]);
	EiCommunicator.send("ZMCC15", "query", _info, ajax_recheckShow_callback); 
} 
var ajax_recheckShow_callback= {
	onSuccess: function(eiInfo) {
		//将查回来的数据填充到ef_region_previewadd表中，为数据新增做好准备
		var block = eiInfo.getBlock("result");  
		if(block.getRows()[0]!=null)
		{
			$('#preview_add-0-fdRecordId').val(block.getCell(0, "fdRecordId")); 
			$('#preview_add-0-fdRecordHandleId').val(block.getCell(0, "fdRecordHandleId")); 
			$('#preview_add-0-fdRecordModifyId').val(block.getCell(0, "fdRecordModifyId")); 
			$('#preview_add-0-fdCreateTime').val(getNowDateTime()); 
			$('#preview_add-0-fdRecheckDate').val(getNowDate()); 

			$('#preview_add-0-fdRecheckerDepartmentId').val($('#fdCreateDepartmentId').val()); 
			$('#preview_add-0-fdRecheckerDepartment').val($('#fdCreateDepartment').val()); 
			$('#preview_add-0-fdRecheckPeopleId').val($('#fdCreatorId').val()); 
			$('#preview_add-0-fdRecheckPeople').val($('#fdCreator').val()); 
			
			hideAllRegions(_regions);
			$('#ef_region_previewadd').show();  
		}
	}
}
button_previewconfirm_onclick = function ()//RECHECK 复查意见 确定
{
	var isCheck = checkRecheck();
  	if (isCheck == 0) {
        return;
    }
  	
	if(efvalidateDiv("ef_region_previewadd")){
		var info = getDetail("ef_region_previewadd","preview_add");
		if (null != info) { 
			EiCommunicator.send("ZMCC15", "insert", info, ajax_previewconfirm_callback);
		} 
	}
} 
var ajax_previewconfirm_callback= {
	onSuccess: function(eiInfo) { 

	 	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCC11","query"); 
		InitRegionShow();
	},
	onFail:function(eMsg)
	{
		SCZXAlertError("操作失败，原因："+eMsg); 
	}
}
button_previewcancel_onclick = function ()//RECHECK 复查意见 返回
{
	InitRegionShow();
} 

/*************************************************************************
*************************************************************************
	延期方法 张坤 2016年3月31日15:44:50
*************************************************************************
*************************************************************************/
button_delay_onclick = function ()//DELAY 延期 
{
	var grid=isSelectedOne("ef_grid_r");
	if (grid == 0)return; 
	var selectedRow=grid.getSelectRowsData()[0]; 
	for(var item in selectedRow){
		var colname=item;
		var colvalue=selectedRow[item];
		$('#result_add-0-'+colname).val(colvalue);
    	if(!colname.indexOf("fdDeadlineDateTime")>=0)
        {
    		$('#result_add-0-'+colname).attr("readonly","readonly");
    		$('#result_add-0-'+colname).attr("disabled","disabled");
        }
	}
	$('#result_add-0-fdProblemDateTime').val($('#result_add-0-fdProblemDate').val()+" "+$('#result_add-0-fdProblemTime').val());
	$('#result_add-0-fdDeadlineDateTime').val($('#result_add-0-fdDeadlineDate').val()+" "+$('#result_add-0-fdDeadlineTime').val());
	$('#result_add-0-fdProblemDateTime').attr("readonly","readonly");
	$('#result_add-0-fdProblemDateTime').attr("disabled","disabled");
	hideAllRegions(_regions);
	$('#ef_region_mainadd').show(); 
} 
/*************************************************************************
*************************************************************************
	罚款方法 张坤2016年3月30日17:21:39
*************************************************************************
*************************************************************************/
button_penalty_onclick = function ()//PENALTY 罚款 
{
	var grid=isSelectedOne("ef_grid_r");
	if (grid == 0)return; 
	var selectedRow=grid.getSelectRowsData()[0]; 
    $('#ef_region_penaltyadd').find("input,select,textarea").each(function ()
    {
    	$(this).val('');
    	$('#penalty_add-0-fdSendnoteDepartmentId').attr("disabled","disabled");
//    	$('#penalty_add-0-fdDepartmentId').attr("disabled","disabled");
    })
	//初始化罚款页面
	$('#penalty_add-0-fdPenalty').val(1);
	$('#penalty_add-0-fdSendnoteDate').val(getNowDate());
	$('#penalty_add-0-fdSendnoteDepartmentId').val($('#fdCreateDepartmentId').val());
	$('#penalty_add-0-fdSendnotePersonId').val($('#fdCreatorId').val()); 
	$('#penalty_add-0-fdSendnotePerson').val($('#fdCreator').val());  
	
	$('#penalty_add-0-fdRecordId').val(selectedRow['fdKeyId']);  
	$('#penalty_add-0-fdDepartmentId').val(selectedRow['fdBusinessDepartmentId']); 
//	departmentChanged();
	hideAllRegions(_regions);
	$('#ef_region_penaltyadd').show(); 
}  



button_penaltyconfirm_onclick = function()// PENALTY 罚款 确定
{
	var isCheck = checkPenalty();
	if (isCheck == 0) {
		return;
	}

	if (efvalidateDiv("ef_region_penaltyadd")) {
		if (isNoSlove == false) {
			var info = getDetailbyBlockname("ef_region_solveadd", "solve_add");
			if (null != info) {
				EiCommunicator.send("ZMCC13", "insert", info, ajax_solveconfirm_callback2); // 下达整改通知
			}
//		} else {
//			var info = getDetailbyBlockname("ef_region_penaltyadd", "penalty_add");
//			if (null != info) {
//				EiCommunicator.send("ZMCC14", "insert", info, ajax_penaltyconfirm_callback);// 罚款
//			}
		}

	}
} 
var ajax_solveconfirm_callback2= {
		onSuccess: function(eiInfo) {
			clearAfterSolve("ef_region_solveadd");
			$('#penalty_add-0-fdRecordId').val(eiInfo.get("fdRecordId"));
			$('#penalty_add-0-fdHandleId').val(eiInfo.get("fdHandleId"));
			var info = getDetailbyBlockname("ef_region_penaltyadd","penalty_add");
			if (null != info) { 
				EiCommunicator.send("ZMCC14", "insert", info, ajax_penaltyconfirm_callback);//罚款
			} 
		},
		onFail:function(eMsg)
		{
			SCZXAlertError("操作失败，原因："+eMsg); 
		}
	}
var ajax_penaltyconfirm_callback= {
	onSuccess: function(eiInfo) {
		var grid = efgrid.getGridObject("ef_grid_p");
		grid.refresh(eiInfo); 
		//查询主表
	 	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCC11","query"); 
		InitRegionShow(); 
		clearAfterSolve("ef_region_penaltyadd");
//		window.parent.location.reload();
	},
	onFail:function(eMsg)
	{
		SCZXAlertError("操作失败，原因："+eMsg); 
	}
}
button_penaltycancel_onclick = function ()//PENALTY 罚款 返回
{
	InitRegionShow();
	clearAfterSolve("ef_region_penaltyadd");
	clearAfterSolve("ef_region_solveadd");
} 
/*************************************************************************
*************************************************************************
	新增方法 张坤2016年3月30日17:21:39
*************************************************************************
*************************************************************************/
button_insert_onclick = function ()//INSERT 新增 
{
    $('#ef_region_mainadd').find("input,select,textarea").each(function ()
    {
    	$(this).val('');
    	var id=$(this).attr("id");
    	if(!(id.indexOf("fdProblemStatus")>=0 || id.indexOf("fdSubmitor")>=0 || id.indexOf("fdCreateUser")>=0 || id.indexOf("fdSubmitorDepartmentId")>=0))
        {
	    	$(this).removeAttr("readonly");
	    	$(this).removeAttr("disabled");
        }
    })
    hideAllRegions(_regions);
    //默认赋值
    $('#result_add-0-fdProblemStatus').val(1);
    $('#result_add-0-fdSubmitorId').val($('#fdCreatorId').val());
    $('#result_add-0-fdCreateUserId').val($('#fdCreatorId').val());
    $('#result_add-0-fdSubmitor').val($('#fdCreator').val());
    $('#result_add-0-fdCreateUser').val($('#fdCreator').val());
    $('#result_add-0-fdSubmitorDepartmentId').val($('#fdCreateDepartmentId').val());
    $('#result_add-0-fdSubmitorDepartment').val($('#fdCreateDepartment').val());
    $('#result_add-0-fdMiningId').val($('#fdMiningId').val());
    $('#result_add-0-fdCreateTime').val(getNowDateTime());
	$('#ef_region_mainadd').show(); 
} 
button_mainconfirm_onclick = function ()//INSERT 主表 确定
{
	var isCheck = checkPQ();
  	if (isCheck == 0) {
        return;
    }
  	
	if(efvalidateDiv("ef_region_mainadd")){
		var info = getDetail("ef_region_mainadd","result_add");
		if (null != info) {
			if($('#result_add-0-fdKeyId').val())
			{
				EiCommunicator.send("ZMCC11", "update", info, ajax_mainconfirm_callback);
			}else
			{
				EiCommunicator.send("ZMCC11", "insert", info, ajax_mainconfirm_callback);
			}
		} 
	}
} 
var ajax_mainconfirm_callback= {
	onSuccess: function(eiInfo) {
		var grid = efgrid.getGridObject("ef_grid_r");
		grid.refresh(eiInfo);//刷新主表grid
		InitRegionShow();  
	},
	onFail:function(eMsg)
	{
		SCZXAlertError("操作失败，原因："+eMsg); 
	}
}
button_maincancel_onclick = function ()//INSERT 主表 返回
{
	InitRegionShow();
};
/*************************************************************************
*************************************************************************
	修改方法 张坤2016年3月30日17:21:39
*************************************************************************
*************************************************************************/
button_update_onclick = function ()//UPDATE 修改 
{
	var grid=isSelectedOne("ef_grid_r");
	if (grid == 0)return; 
	var selectedRow=grid.getSelectRowsData()[0]; 
//	if(selectedRow["fdProblemStatus"]!=0)
//	{
//		SCZXAlertError("只能修改状态为草拟的记录！");
//		return;
//	} 
	 
	for(var item in selectedRow){
		var colname=item;
		var colvalue=selectedRow[item];
		$('#result_add-0-'+colname).val(colvalue);
    	if(!(colname.indexOf("fdProblemStatus")>=0 || colname.indexOf("fdSubmitor")>=0 || colname.indexOf("fdCreateUser")>=0 ||colname.indexOf("fdSubmitorDepartmentId")>=0))
        {
    		$('#result_add-0-'+colname).removeAttr("readonly");
    		$('#result_add-0-'+colname).removeAttr("disabled");
        }
	} 
	$('#result_add-0-fdProblemDateTime').val($('#result_add-0-fdProblemDate').val()+" "+$('#result_add-0-fdProblemTime').val());
	$('#result_add-0-fdDeadlineDateTime').val($('#result_add-0-fdDeadlineDate').val()+" "+$('#result_add-0-fdDeadlineTime').val());
	hideAllRegions(_regions);
	$('#ef_region_mainadd').show(); 
} 
/*************************************************************************
*************************************************************************
	作废 关闭 打印 方法 张坤2016年3月30日17:21:39
*************************************************************************
*************************************************************************/
button_invalid_onclick = function ()//INVALID 作废 
{
// 	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCC11","invalid"); 
	if (isSelected("ef_grid_r") == 0)
		return; 
	var info = getSCZXEiInfos("ZMCC10","ef_grid_r");
	if (null != info) { 
		EiCommunicator.send("ZMCC11", "invalid", info, validate_callback);
	}
} 
button_close_onclick = function ()//CLOSE 关闭 
{
// 	efgrid.submitInqu( "ef_grid_r", "ZM","ZMCC11","close"); 
	if (isSelected("ef_grid_r") == 0)
		return; 
	var info = getSCZXEiInfos("ZMCC10","ef_grid_r");
	if (null != info) { 
		EiCommunicator.send("ZMCC11", "close", info, validate_callback);
	}
} 

var validate_callback={
		onSuccess:function(eiInfo){
			if(eiInfo.getStatus()==-1){
				EFAlert("操作失败，原因："+eiInfo.getMsg());
			}else{
				 efwindow.hide();
				 var grid = efgrid.getGridObject("ef_grid_r");
				 grid.refresh(eiInfo);
//				window.parent.location.reload();
			}
		},
		onFail:function(eMsg)
		{
			EFAlert("操作失败，原因："+eMsg); 
		}
}
button_print_onclick = function ()//PRINT 打印
{
}  
/*************************************************************************
*************************************************************************
	点击主表查询从表方法 张坤2016年3月30日17:21:39
*************************************************************************
*************************************************************************/
efgrid_onRowClicked = function( grid_id, row_index ){//点击主表行查询从表数据
	if(grid_id == "ef_grid_r"){ 
		var grid = efgrid.getGridObject(grid_id);
		var fdKeyId=grid.getCellValueByColumnName(row_index,"fdKeyId"); 
		var fdPenaltyIds=grid.getCellValueByColumnName(row_index,"fdPenaltyIds"); 
		
		$('#fdDepartmentId').val(grid.getCellValueByColumnName(row_index,"fdBusinessDepartmentId"));//记录责任部门
		var info = new EiInfo();
		info.set("fdKeyId",fdKeyId);    
		EiCommunicator.send("ZMCC13", "query", info, ajax_select_callback);  
		var info1 = new EiInfo();
		info1.set("fdPenaltyIds",fdPenaltyIds); 
		EiCommunicator.send("ZMCC14", "query", info1, ajax_select_callback1); 
	}
}
var ajax_select_callback= {
	onSuccess: function(eiInfo) { 
		 efwindow.hide();
		 var grid = efgrid.getGridObject("ef_grid_s");
		 grid.refresh(eiInfo);
	},
	onFail:function(eMsg)
	{
		EFAlert("新增失败，原因："+eMsg); 
	}
}
var ajax_select_callback1= {
	onSuccess: function(eiInfo) { 
		 efwindow.hide();
		 var grid = efgrid.getGridObject("ef_grid_p");
		 grid.refresh(eiInfo);
	},
	onFail:function(eMsg)
	{
		EFAlert("新增失败，原因："+eMsg); 
	}
}


/*************************************************************************
*************************************************************************
	其他方法 张坤2016年3月30日17:21:39
*************************************************************************
*************************************************************************/
//加载主表状态字段的颜色
efgrid_onCellDisplayReady = function( div_node_html, row_index, col_index, col_value_c, display_value ,grid_id)
{	
   var grid_obj = efgrid.getGridObject(grid_id);
   var columnEname = grid_obj.getColumn(col_index, TYPE_DATA).getEname();
   if( columnEname == "fdProblemStatus"  &&  grid_id=="ef_grid_r")
	{  
	 	var isNewLine = grid_obj.isNewLine(row_index);
        if(!isNewLine)
        {
            var html = "";
            if (col_value_c == "1") html = "<div align=center><font color='blue'>"+display_value+"</font></div>";   
            else if (col_value_c == "2") html = "<div align=center><font color='green'>"+display_value+"</font></div>";   
            else if (col_value_c == "3") html = "<div align=center><font color='red'>"+display_value+"</font></div>";   
            else if (col_value_c == "4") html = "<div align=center><font color='grey'>"+display_value+"</font></div>";   
            else if (col_value_c == "5") html = "<div align=center><font color='orange'>"+display_value+"</font></div>";   
            else html = "<div align=center>"+display_value+"</div>";   
            return html; 
        }else
        {	
            return;
        }
	}	
}
function changeDateAndTime(blockName,fieldPre)
{
	var dateTime=$('#'+blockName+'-0-'+fieldPre+'DateTime').val();
	var date=dateTime.substring(0,10);
	var time=dateTime.substring(11);
	$('#'+blockName+'-0-'+fieldPre+'Date').val(date);
	$('#'+blockName+'-0-'+fieldPre+'Time').val(time);
}

/*
 * 生产问题——输入项数据校验
 */
function checkPQ() {
	var fdProblemDateTime = $("#result_add-0-fdProblemDateTime").val(); // 发生时间
	var fdDeadlineDateTime = $("#result_add-0-fdDeadlineDateTime").val(); // 解决时间

	var fdProblemPlace = $("#result_add-0-fdProblemPlace").val().trim(); // 发生地点
	var fdProblemDescription = $("#result_add-0-fdProblemDescription").val().trim(); // 问题描述
	var fdBusinessMan = $("#result_add-0-fdBusinessMan").val().trim(); // 责任人
	var fdRemarks = $("#result_add-0-fdRemarks").val().trim(); // 备注

	if (fdProblemPlace == "") {
		SCZXAlert("发生地点不能为空！");
		return false;
	} else if (fdProblemPlace.getBytes() > 250 || fdProblemPlace.getBytes() < 1) {
		SCZXAlert("[发生地点]请输入1~250个字符！");
		return false;
	}

	if (fdBusinessMan == "") {
		SCZXAlert("责任人不能为空！");
		return false;
	} else if (fdBusinessMan.getBytes() > 10 || fdBusinessMan.getBytes()< 1) {
		SCZXAlert("[责任人]请输入1~10个字符！");
		return false;
	}
	
	if (fdProblemDescription == "") {
		SCZXAlert("问题描述不能为空！");
		return false;
	} else if (fdProblemDescription.getBytes() > 400
			|| fdProblemDescription.getBytes() < 1) {
		SCZXAlert("[问题描述]请输入1~400个字符！");
		return false;
	}

	if (fdRemarks.getBytes() > 250) {
		SCZXAlert("备注不能超过250个字符！");
		return false;
	}

	if (fdProblemDateTime == "") {
		SCZXAlert("发生时间不能为空！");
		return false;
	}
	if (fdDeadlineDateTime == "" || fdDeadlineDateTime == 0) {
		SCZXAlert("解决时间不能为空！");
		return false;
	} else {
		if (getDateValue(fdProblemDateTime) > getDateValue(fdDeadlineDateTime)) {
			SCZXAlert("发生时间不能晚于解决时间，请重新输入！");
			return false;
		}
	}

	return true;
}
 
/**
 * 处理——输入项校验
 */
function checkHandle() {
	var fdSuggestion = $("#solve_add-0-fdSuggestion").val().trim(); // 处理意见

	if (fdSuggestion == "") {
		SCZXAlert("处理意见不能为空！");
		return false;
	} else if (fdSuggestion.getBytes() > 500) {
		SCZXAlert("处理意见不能超过500个字符！");
		return false;
	}
	return true;
}

/**
 * 罚款——输入项校验
 */
function checkPenalty() {
	var fdPenalty = $("#penalty_add-0-fdPenalty").val(); // 罚款金额
	var fdPeopleName = $("#penalty_add-0-fdPeopleName").val().trim(); // 责任人
	var fdReason = $("#penalty_add-0-fdReason").val().trim(); // 罚款原因
	var fdRemarks = $("#penalty_add-0-fdRemarks").val().trim(); // 备注
		 
	if (!IsNum(fdPenalty)) {
		SCZXAlert("罚款金额应输入长度不超过6位的正整数！");
		return false;
	}
	
	if (fdPeopleName == "") {
		SCZXAlert("责任人不能为空！");
		return false;
	} else if (fdPeopleName.getBytes() > 10 || fdPeopleName.getBytes()< 1) {
		SCZXAlert("[责任人]请输入1~10个字符！");
		return false;
	}
	
	if (fdReason == "") {
		SCZXAlert("罚款原因不能为空！");
		return false;
	} else if (fdReason.getBytes() > 250
			|| fdReason.getBytes() < 1) {
		SCZXAlert("[罚款原因]请输入1~250个字符！");
		return false;
	}

	if (fdRemarks.getBytes() > 100) {
		SCZXAlert("备注不能超过100个字符！");
		return false;
	}
	
	return true;
}

/**
 * 复查——输入项校验
 */
function checkRecheck() {
	var fdCondition = $("#preview_add-0-fdCondition").val().trim(); // 复查情况描述
	var fdRedoSuggestion = $("#preview_add-0-fdRedoSuggestion").val().trim(); // 重新整改意见
	
	
	if (fdCondition.getBytes() > 100) {
		SCZXAlert("复查情况描述不能超过100个字符！");
		return false;
	}
	if (fdRedoSuggestion.getBytes() > 100) {
		SCZXAlert("重新整改意见备注不能超过100个字符！");
		return false;
	}
	return true;
}

String.prototype.getBytes = function() {      
    var cArr = this.match(/[^\x00-\xff]/ig);      
    return this.length + (cArr == null ? 0 : cArr.length);   
      
}  

String.prototype.trim=function(){
    return this.replace(/(^\s*)|(\s*$)/g, "");
 }
/*
根据传入的String类型的date获取该日期对应的毫秒值，传入的字符串格式为：yyyy-MM-dd HH:mm:ss
*/
function getDateValue(dateStr) {
   var tt = dateStr.split(" ");
   var ttt1 = tt[0].split("-");
   var ttt2 = tt[1].split(":");
   var date1 = new Date(ttt1[0], ttt1[1], ttt1[2], ttt2[0], ttt2[1], ttt2[2]);
   var m1 = date1.getTime();
   return m1;
}

/*
判断一个变量是不是不超过6位的正整数
*/
function IsNum(num){
var reNum=/^[1-9]\d{0,5}?$/;
return(reNum.test(num));
}

/**
 * 操作完成后清空该region内的各数据项的值
 */
var clearAfterSolve=function(region) { 
	var temp;
	//遍历INPUT
	$('#'+region).find("input").each(function (){
		temp = $(this).attr("id");
		$('#'+temp).val("");
//		$(this).removeData();
	});
	//遍历SELECT
	$('#'+region).find("select").each(function (){
		temp = $(this).attr("id");
		$('#'+temp).val("");
	});
	//遍历TEXTAREA
	$('#'+region).find("textarea").each(function (){
		temp = $(this).attr("id");
		$('#'+temp).val("");
	});
};